import { LoginUser, RouterContext } from "f2e-server3";

export interface ServerConfig {
    docDir: string;
}
export interface ServerResult<T = never> {
    success: boolean;
    message?: string;
    data: T;
}
export interface ServerAPI<T = any, F = any> {
    (data: T, ctx: RouterContext): Promise<ServerResult<F>>;
}

export type ClientAPI<R extends ServerAPI> = R extends ServerAPI<infer T, infer F> ? (data: T) => Promise<ServerResult<F>> : never;

/**
 * 用户应用站点
 */
export interface UserApp {
    id: number;
    /**
     * 站点标题
     */
    title: string;
    /**
     * 站点描述
     */
    description?: string;
    /**
     * 开启后非叶子节点的文档将不可点击
     */
    hideParent?: boolean;
    createdAt: string;
    updatedAt: string;
    createdBy: string;
    updatedBy: string;
    editors: string[];
}
export interface UserAppTree {
    /**
     * 文档索引
     */
    id: number;
    /**
     * 文档标题
     */
    title: string;
    /**
     * 文档索引
     */
    parentId?: number;
    /**
     * 文档描述
     */
    description?: string;
}
export interface UserAppDetail {
    /**节点索引最大值 */
    tree_max_index: number;
    tree: UserAppTree[];
}
/**
 * 用户信息包含站点
 */
export interface UserProfile extends LoginUser {
    max_app_index: number;
    apps: UserApp[];
}